package io.terminus.lego.shinda.service.model

import io.terminus.lego.shinda.service.annotation.NoArg
import io.terminus.lego.shinda.web.controller.dto.UserDTO
import java.io.Serializable
import java.util.*
import javax.persistence.*

/**
 * @author wangmeng
 * @date 2018/4/14
 */
@NoArg
@Entity
@Table(name = "uc_users")
data class User(
        @field:Id
        @field:GeneratedValue(strategy = GenerationType.IDENTITY)
        val id: Long? = null,
        val phone: String? = null,
        val email: String? = null,
        val avatarUrl: String? = null,
        val username: String? = null,
        val password: String? = null,
        val realName: String? = null,
        val nickName: String? = null,
        val enabled: Boolean = true,
        val birthday: Date? = null,
        val createdAt: Date? = null,
        val updatedAt: Date? = null
) : Serializable

fun User.toDTO(): UserDTO {
    return UserDTO(id, phone, email, avatarUrl, username, realName, nickName, enabled, birthday, createdAt, updatedAt)
}